﻿namespace FallingWordsGame
{
    using System;
    using System.Collections.Generic;

    //TODO: Generator for GameObjects

    public class WordGenerator
    {
        private Random random;
        private IList<string> wordDataBase;
        //private IList<IList<string>> blockDataBase;
        private int maxWidth;

        public WordGenerator(IList<string> wordDataBase, int width)
        {
            this.wordDataBase = wordDataBase;
            maxWidth = 3 * width / 4;
            random = new Random();
        }

        private int GetCoordinates(int wordLength)
        {
            return random.Next(0, maxWidth - wordLength);
        }

        public Word NewWord()
        {
            int randomNumIndex = random.Next(0, wordDataBase.Count - 1);
            string randomWord = wordDataBase[randomNumIndex];
            return new Word(randomWord);
        }

        public GameObject NextSingleLineText()
        {
            var word = this.NewWord();
            var coords = new Coords(0, this.random.Next(0, this.maxWidth));
            return new SingleLineText(word, coords);
        }
    }
}
